Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: adapt contract when fetching all option lists to visualize error per option list #14269

Merged

Conversation

standeren
Copy link
Contributor

@standeren standeren commented Dec 12, 2024

Description

  • change contract in get all option lists endpoint in order to return all option lists, independent of being healthy or faulty. If faulty the data prop is swapped with the hasError prop.
Skjermbilde 2024-12-12 kl  10 52 48

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

@github-actions github-actions bot added area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. solution/studio/designer Issues related to the Altinn Studio Designer solution. backend frontend labels Dec 12, 2024
@standeren standeren force-pushed the imporove-error-handling-for-get-all-option-lists-endpoint branch from 13df12e to 9ef1ecd Compare December 12, 2024 10:07
@standeren standeren marked this pull request as draft December 12, 2024 10:12
@standeren standeren force-pushed the imporove-error-handling-for-get-all-option-lists-endpoint branch from 9ef1ecd to bf44f5a Compare December 12, 2024 10:13
@standeren standeren linked an issue Dec 12, 2024 that may be closed by this pull request
@standeren standeren force-pushed the imporove-error-handling-for-get-all-option-lists-endpoint branch 2 times, most recently from 0273996 to 6caaae9 Compare December 18, 2024 08:17
@github-actions github-actions bot added the quality/testing Tests that are missing, needs to be created or could be improved. label Dec 18, 2024
@standeren standeren force-pushed the imporove-error-handling-for-get-all-option-lists-endpoint branch from 6caaae9 to 180f682 Compare December 18, 2024 09:41
@standeren standeren force-pushed the imporove-error-handling-for-get-all-option-lists-endpoint branch 3 times, most recently from efca53c to 6988b6d Compare December 20, 2024 14:27
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 97.95918% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.53%. Comparing base (4275f06) to head (f50c391).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...s/ux-editor/src/components/Elements/ExportForm.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14269   +/-   ##
=======================================
  Coverage   95.53%   95.53%           
=======================================
  Files        1859     1859           
  Lines       24076    24091   +15     
  Branches     2777     2779    +2     
=======================================
+ Hits        23001    23016   +15     
  Misses        817      817           
  Partials      258      258           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@standeren standeren marked this pull request as ready for review December 20, 2024 14:44
@standeren standeren added skip-releasenotes Issues that do not make sense to list in our release notes team/studio-domain1 skip-documentation Issues where updating documentation is not relevant labels Dec 20, 2024
@standeren standeren force-pushed the imporove-error-handling-for-get-all-option-lists-endpoint branch from 2852847 to 9da552c Compare January 1, 2025 16:02
@ErlingHauan ErlingHauan self-assigned this Jan 3, 2025
@ErlingHauan
Copy link
Contributor

Testing

Studio crashed when uploading this code list in Gitea:

[
  {
    "label": "Yes",
    "value": "yes",
    "invalidProperty": true
  }
]

With the following error:

optionListsData.map is not a function
convertOptionsListsDataToCodeListsData
...

The error still occurs when:

  • Deleting all code lists from repo in Gitea
  • Uploading a valid code list to Gitea

Are you able to reproduce this? This was tested in localhost.

@ErlingHauan ErlingHauan removed their assignment Jan 3, 2025
@standeren
Copy link
Contributor Author

Testing

Studio crashed when uploading this code list in Gitea:

[
  {
    "label": "Yes",
    "value": "yes",
    "invalidProperty": true
  }
]

With the following error:

optionListsData.map is not a function
convertOptionsListsDataToCodeListsData
...

The error still occurs when:

  • Deleting all code lists from repo in Gitea
  • Uploading a valid code list to Gitea

Are you able to reproduce this? This was tested in localhost.

Hm, I tested locally now, and I am not able to reproduce it 🤔 It actually looks like the backend does not care about additional properties so I do not get any error at all. The error occurs if trying to set an object e.g. as the value for the value-key.

But I did try setting the label-value to an object and removing the label-field; both results in 500 in backend, which is not suppose to happen. But I guess that is issue that exists from before. On the other hand, this PR might be the correct place to fix it tho 🤷

@standeren standeren assigned ErlingHauan and unassigned standeren Jan 3, 2025
@ErlingHauan
Copy link
Contributor

ErlingHauan commented Jan 3, 2025

Hm, I tested locally now, and I am not able to reproduce it 🤔 It actually looks like the backend does not care about additional properties so I do not get any error at all. The error occurs if trying to set an object e.g. as the value for the value-key.

But I did try setting the label-value to an object and removing the label-field; both results in 500 in backend, which is not suppose to happen. But I guess that is issue that exists from before. On the other hand, this PR might be the correct place to fix it tho 🤷

I tried restarting the local dev servers, and that seemed to fix it. My bad.
It works now:
bilde

I also noticed that trailing commas in the JSON file resulted in a 500 error, which caused the frontend error optionListsData.map is not a function to appear. Maybe I was experiencing a 500 error earlier today, and that caused the frontend to act up.

I think we should collect the 500 errors in a different issue, since it's not part of your scope 😊

Edit: see new issue here - #14351

Copy link
Contributor

@ErlingHauan ErlingHauan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test OK 👍

@ErlingHauan ErlingHauan merged commit 1b719b9 into main Jan 3, 2025
17 checks passed
@ErlingHauan ErlingHauan deleted the imporove-error-handling-for-get-all-option-lists-endpoint branch January 3, 2025 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. backend frontend quality/testing Tests that are missing, needs to be created or could be improved. skip-documentation Issues where updating documentation is not relevant skip-releasenotes Issues that do not make sense to list in our release notes solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-domain1
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Fetch optionLists in individual requests
3 participants